package com.jiepos.mpos.biz.review.controller;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.jiepos.mpos.biz.affix.service.AppAffixInfService;
import com.jiepos.mpos.biz.customer.service.AppCustomerInfoService;
import com.jiepos.mpos.biz.customer.service.CustomBankcardInfoService;
import com.jiepos.mpos.biz.review.service.MemReviewDoneService;
import com.jiepos.mpos.common.entity.MemReviewEntity;
import com.jiepos.mpos.core.controller.BaseController;
import com.jiepos.mpos.core.entity.Pagination;
import com.jiepos.mpos.core.util.StringUtils;

/**
 * 实名认证已办事项控制层
 * @ClassName: MemReviewDoneController
 * @Description: 审核管理控制层
 * @author 张磊
 * @date 2017年9月21日 下午3:03:34
 *
 */
@Controller
@RequestMapping("memreviewdone")
public class MemReviewDoneController extends BaseController {

	@Autowired
	private MemReviewDoneService memReviewDoneService;
	
	@Autowired
	private AppCustomerInfoService appCustomerInfoService;
	
	@Autowired
	private CustomBankcardInfoService customBankcardInfoService;
	
	@Autowired
	private AppAffixInfService appAffixInfService;
	
	/**
	 * 进入实名认证已办事项页面
	 * 
	 * @param request
	 * @param response
	 * @param pagination
	 * @return
	 */
	@RequestMapping("/getMemReviewDoneList.do")
	public ModelAndView getMemReviewDoneList(Pagination pagination, HttpServletRequest request,HttpServletResponse response,MemReviewEntity memReviewEntity){
		ModelAndView model = new ModelAndView("/module/review/memcertifidone/memcertifidone_list");
		return super.getDetail(request, response, model);
	}
	
	@RequestMapping("/getMemReviewDoneListJson.do")
	public @ResponseBody Map getMemReviewListJson(HttpServletRequest request, HttpServletResponse response,
			Pagination pagination,MemReviewEntity memReviewEntity){
		return memReviewDoneService.getMemReviewDoneList(pagination,request,memReviewEntity);
	}
	
	@RequestMapping("/getMemReviewDoneCommonDetail.do")
	public ModelAndView getMemReviewDoneCommonDetail(HttpServletRequest request, HttpServletResponse response, String custom_uuid){
		ModelAndView modelAndView = new ModelAndView("/module/customer/customerinfo/customerinfo_common_detail");
		if(!StringUtils.isEmpty(custom_uuid)){
			Map customInfEntity = appCustomerInfoService.getCustomerInfoByUUID(custom_uuid);
			Map appCustomBankEntity = customBankcardInfoService.getCustomBankcardInfoPass(custom_uuid);
			if(appCustomBankEntity == null){
				appCustomBankEntity = customBankcardInfoService.getCustomBankcardInfoBack(custom_uuid);
			}
			List<Map<String, Object>> picList = appAffixInfService.getCustomCertificatePic(custom_uuid);
			modelAndView.addObject("appCustomerInfEntity", customInfEntity);
			modelAndView.addObject("appCustomBankEntity", appCustomBankEntity);
			modelAndView.addObject("picList", picList);
		}
		return super.getDetail(request, response, modelAndView);
	}
	
	@RequestMapping("/getMemReviewDoneDetail.do")
	public ModelAndView getMemReviewDoneDetail(HttpServletRequest request, HttpServletResponse response, String custom_uuid){
		ModelAndView modelAndView = new ModelAndView("/module/review/memcertifidone/memcertifidone_detail");
		modelAndView.addObject("custom_uuid", custom_uuid);
		return super.getDetail(request, response, modelAndView);
	}
	
}
